﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp.Study.Test
{
    public class 递归测试
    {
        public static List<Model> Models { get; set; } = new List<Model>();
        public static void Go()
        {
            for (int i = 0; i < 10; i++)
            {
                var subs = new List<Model>();
                for (int j = 0; j < 3; j++)
                {
                    subs.Add(new Model
                    {
                        Id = $"{i}_{j}"
                    });
                }
                Models.Add(new Model
                {
                    Id = i.ToString(),
                    Models = subs
                });
            }

          
        }


        private static void DiGui(List<Model> list, int page_index, string pId = "")
        {
            bool hasmore = false;
            while (hasmore)
            {
                var models = Models.Where(x=>pId=="").OrderBy(x => x.Id).Take(5).ToList();
                foreach (var model in models)
                {
                    if(model.Models!=null && model.Models.Count > 0)
                    {
                        DiGui(list, page_index, model.Id);
                    }
                }
            }
        }


        public class Model
        {
            public string Id { get; set; }

            public List<Model> Models { get; set; }
        }
    }
}
